<template>
	<view>
		<view class="input user">
			用户名：<u--input v-model="username"></u--input>
		</view>
		<view class="input pass">
			密&nbsp;&nbsp;&nbsp;码：<u--input v-model="password"></u--input>
		
		</view>
		<view class="text">
			<text>没有账号？  <text class="reg" @click="gotoreg">去注册</text></text>
		</view>
			<view class="butbox">
			<view class="but"><button type="primary" @click="gologin">登录</button></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				 username:'',
				 password:'',
			}
		},
		methods: {
			gotoreg(){
				uni.navigateTo({
					url:'/pages/reg/reg'
				})
			},
			gologin(){
				console.log(this.username,this.password);
				let username=this.username
				let password=this.password
				uni.request({
					url:'http://localhost:8000/api/login',
					method:'GET',
					data:{
						username,password
					},
					success({data}){
						uni.setStorageSync('token',username);
						console.log(data);
						uni.navigateBack()
					}
				})
			},
		}
	}
</script>

<style>
.input{
	display: flex;margin: 50rpx;
	align-items: center;
}
.butbox{
	width: 100%;
	display: flex;
	justify-content: center;
}
.but{
	width: 650rpx;
}
.text{
	width: 500rpx;
	height: 50rpx;
	/* background: yellow; */
	margin-left: 55rpx;
}
.reg{
	color: rgb(34,167,242);
}
</style>
